package ${packageName}.service.impl.${moduleName};

import ${packageName}.mapper.pgsql.${moduleName}.${classInfo.className}Mapper;
import ${packageName}.model.entity.${moduleName}.${classInfo.className};
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import ${packageName}.service.${moduleName}.${classInfo.className}Service;


import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.dbapp.dsc.exceptions.DscException;
import com.dbapp.dsc.model.common.PageResult;
import com.dbapp.dsc.model.dto.${moduleName}.${classInfo.className}DTO;
import com.dbapp.dsc.model.dto.${moduleName}.${classInfo.className}QueryDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author ${authorName} ${.now?string('yyyy-MM-dd')}
 */
@Service
public class ${classInfo.className}ServiceImpl implements ${classInfo.className}Service  {
    @Autowired
    private ${classInfo.className}Mapper ${classInfo.className?uncap_first}Mapper;

    @Override
    public void add(${classInfo.className}DTO dto) {
        ${classInfo.className} doman = new ${classInfo.className}();
        BeanUtil.copyProperties(dto,doman);
        int insert = ${classInfo.className?uncap_first}Mapper.insert(doman);
        if(insert <= 0){
        throw new DscException("新增失败");
        }
    }

    @Override
    public void delete(Long id) {
        int insert = ${classInfo.className?uncap_first}Mapper.deleteById(id);
        if(insert <= 0){
        throw new DscException("删除失败");
        }
    }

    @Override
    public List<${classInfo.className}DTO> list(${classInfo.className}DTO dto) {

        LambdaQueryWrapper<${classInfo.className}> wrapper = new LambdaQueryWrapper<>();
        //TODO
        return null;
    }

    @Override
    public void update(${classInfo.className}DTO dto) {
        ${classInfo.className} doman = new ${classInfo.className}();
        BeanUtil.copyProperties(dto,doman);
        int i = ${classInfo.className?uncap_first}Mapper.updateById(doman);
        if(i <= 0){
        throw new DscException("新增失败");
        }

    }

    @Override
    public PageResult<${classInfo.className}DTO> page(${classInfo.className}QueryDTO dto) {
        //TODO
        return null;
    }

}